//    Copyright (C) Kherty.  All rights reserved.
namespace OpenLS.Spreadsheet
{
    partial class Cell
	{
        internal DataBarInformation DataBar
        {
            get
            {
                if (!HasExtraData)
                    return null;
                return EnsureExtraData.DataBar;
            }
            set
            {
                if (value == null)
                {
                    if (HasExtraData)
                    {
                        ExtraData.DataBar = value;
                        ForgetExtraData();
                    }
                }
                else
                {
                    EnsureExtraData.DataBar = value;
                }
                notifyNonRecordPropertyChanged(CellProperties.DataBar);
                Worksheet.OnCellBorderOrBackgroundChanged(this);
            }
        }
        internal IconSetInformation Icon
        {
            get
            {
                if (!HasExtraData)
                    return null;
                return EnsureExtraData.Icon;
            }
            set
            {
                if (value == null)
                {
                    if (HasExtraData)
                    {
                        ExtraData.Icon = value;
                        ForgetExtraData();
                    }
                }
                else
                {
                    EnsureExtraData.Icon = value;
                }
                notifyNonRecordPropertyChanged(CellProperties.Icon);
                Worksheet.OnCellBorderOrBackgroundChanged(this);

            }
        }
        internal ColorScaleInformation ColorScale
        {
            get
            {
                if (!HasExtraData)
                    return null;
                return EnsureExtraData.ColorScale;
            }
            set
            {
                if (value == null)
                {
                    if (HasExtraData)
                    {
                        ExtraData.ColorScale = value;
                        ForgetExtraData();
                    }
                }
                else
                {
                    EnsureExtraData.ColorScale = value;
                }
                notifyNonRecordPropertyChanged(CellProperties.ColorScale);
                Worksheet.OnCellBorderOrBackgroundChanged(this);

            }
        }
        internal DifferentialStyleRecord DifferentialStyleRecord
        {
            get
            {
                if (!HasExtraData)
                    return null;
                return ExtraData.DifferentialStyleRecord;
            }
            set
            {
                if (value == null)
                {
                    if (HasExtraData)
                    {
                        ExtraData.DifferentialStyleRecord = null;
                        ForgetExtraData();
                        NotifyDifferentialStyleRecordChanged();
                        return;
                    }
                }
                else
                {
                    EnsureExtraData.DifferentialStyleRecord = value;
                    NotifyDifferentialStyleRecordChanged();
                }
            }
        }

        private void NotifyDifferentialStyleRecordChanged()
        {
            notifyNonRecordPropertyChanged(CellProperties.DifferentialStyleRecord);
            notifyNonRecordPropertyChanged(CellProperties.ActualBackground);
            notifyNonRecordPropertyChanged(CellProperties.ActualForeground);
            notifyNonRecordPropertyChanged(CellProperties.ActualBorders);
            notifyNonRecordPropertyChanged(CellProperties.ActualFontStyle);
            notifyNonRecordPropertyChanged(CellProperties.ActualFontWeight);
            notifyNonRecordPropertyChanged(CellProperties.ActualFontUnderline);
        }

        internal void ResetConditionalFormatting(ConditionalFormatting c)
        {
            if (HasExtraData)
            {
                ExtraData.ResetConditionalFormattingInformation(c);
                ForgetExtraData();
                NotifyDifferentialStyleRecordChanged();
                notifyNonRecordPropertyChanged(CellProperties.DataBar);
                notifyNonRecordPropertyChanged(CellProperties.ColorScale);
            }
        }
    }

}
